import os
import sys
import django

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.extend([BASE_DIR, ])
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "finance_c2c.settings")
django.setup()
from apps.sales_man.models import SalesMan, BoundRelation


def delete_salesman(tel):
    salesman = SalesMan.objects.get(tel=tel)
    openid = salesman.wx_user.openid
    relation_obj = BoundRelation.objects.filter(openid=openid)
    relation_obj.delete()
    salesman.wx_user = None
    salesman.tel = None
    salesman.save()


if __name__ == '__main__':
    delete_salesman("18612345440")
